<?php
  include( "templates/include/header.php" );
  include( "templates/include/adminHeader.php" );

  function displayCategory( $match ) {
    switch ( $match->category ) {
      case 'seniora':
        echo("Senior A");
        break;
      case 'seniorb':
        echo("SeniorB");
        break;
      case 'u18':
        echo("U-18");
        break;
      case 'u15':
        echo("U-15");
        break;
      case 'u13':
        echo("U-1");
        break;
      case 'u11':
        echo("U-11");
        break;
      case 'u9':
        echo("U-9");
        break;
      case 'u67':
        echo("U-6-7");
        break;
      default:
        echo("General");
    }
  }
?>

      <div id="adminHeader" >
        <h2>Administation de l'Agenda</h2>
        <p>Vous &ecirc;tes connect&eacute; en tant que <b><?php echo htmlspecialchars( $_SESSION['username']) ?></b>. <a href="admin.php?action=logout"?>Se D&eacute;connecter</a></p>
      </div>

      <h1>Tous les Evenements</h1>

<?php if ( isset( $results['errorMessage'] ) ) { ?>
        <div class="errorMessage"><?php echo $results['errorMessage'] ?></div>
<?php } ?>


<?php if ( isset( $results['statusMessage'] ) ) { ?>
        <div class="statusMessage"><?php echo $results['statusMessage'] ?></div>
<?php } ?>


  <table align="center" width="90%" border="1px" cellpadding="1px" cellspacing="1px" class="Schedule">
    <thead>
			<tr>
				<th width="100px">Quand</th>
				<th width="150px">O&uacute;</th>
				<th width="100px">Cat&eacute;gorie</th>
				<th>Description</th>
			</tr>
		</thead>
		<tbody>
		<?php foreach ( $results['match'] as $match ) { ?>
          <tr class="<?php echo $match->category ?>" onclick="location='admin.php?action=editMatch&amp;matchId=<?php echo $match->id?>'">
            <td valign="middle" style="margin:0;padding:0" align="center" width="100px">
              <?php
                $tmp = explode(" ", $match->eventDate);
                echo( $tmp[0] . "</br>" . $tmp[1] );
              ?>
            </td>
            <td valign="middle" align="center" width="150px">
              <?php echo $match->location ?>
            </td>
            <td valign="middle" align="center" width="100px">
              <?php displayCategory( $match ); ?>
            </td>
            <td valign="middle" align="left">
              <?php echo htmlspecialchars( $match->descript ); ?>
            </td>
          </tr>
        <?php } ?>
    </tbody>
  </table>


      <p><?php echo $results['totalRows']?> article<?php echo ( $results['totalRows'] != 1 ) ? 's' : '' ?> au total.</p>

      <p><a href="admin.php?action=newMatch">Ajouter un Evenement</a></p>

<?php
  include( "templates/include/adminFooter.php" );
  include( "templates/include/footer.php" ); ?>
